package com.ftg.learn.privilege.mapper;

import com.ftg.learn.privilege.entity.Dept;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;

/**
 * spring 类容器：存放的大量java类
 * 采用新技术
 * 注解 代替xml
 */
@Mapper
public interface DeptMapper {

    @Select("select * from dept")
    List<Dept> showAll();

    @Select("select * from dept where dname like concat('${param1}','%')")
    List<Dept> showAllForName(String name);

    @Select("select * from dept where deptno > #{param1} and deptno < #{param2}")
    List<Dept> gtlt(Integer p1, Integer p2);

    @Insert("insert into dept(deptno,dname,loc) values(#{deptno},#{dname},#{loc})")
    int saveDept(Dept dept);

    @Select("select * from dept where deptno = #{param1}")
    List<Dept> findByPrimary(Integer deptno);


    @Update("update dept set dname =#{dname},loc=#{loc} where deptno = #{deptno}")
    int updateDept(Dept dept);

    @Delete("delete from dept where deptno = #{param1}")
    int deleteDept(Integer deptno);

}
